Repository navigation
deps: update lolhtml to v2.7.1 - #17
Open
github-actions[bot] wants to merge 1 commit into
Open
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
github-actions
Bot
force-pushed
the
deps/update-lolhtml-7
branch
from
January 25, 2026 01:31
31e1089 to
a2e954f
Compare
crishoj
pushed a commit
that referenced
this pull request
Jul 29, 2026
…ry rewrite (oven-sh#34271) `test/js/bun/util/filesystem_router.test.ts` went red on alpine x64 in build [73276](https://buildkite.com/bun/bun/builds/73276): the `reload() while Bun.build() resolves the same directory` subprocess segfaulted in `bust_dir_cache_recursive`, inlined from `NonNull::new`. ## Cause `RealFS::entries_at` (`src/resolver/lib.rs`) replaces a cached `DirEntry` in place when the caller's resolver generation is newer than the cached listing's. The replacement at `*e_ptr = new_entry` drops the old `DirEntry`, which drops its `data: StringHashMap<*mut Entry>` and frees the hashmap's bucket allocation. The function's comment says `entries_mutex held by caller`, but that is only true on one of the five paths that reach it: `dir_info_uncached`, when entered from `dir_info_cached_miss`. The other callers (`finalize_result`, `handle_esm_resolution`, `load_index_with_extension`, `Transpiler::run_env_loader`) all reach `entries_at` after `dir_info_cached_maybe_log` has already returned and released both `RESOLVER_MUTEX` and `entries_mutex`. `FileSystemRouter::reload()` and `RouteLoader::load` iterate the same `DirEntry.data` map under `entries_mutex` (the snapshot pattern oven-sh#33056 introduced for exactly this kind of concurrent rewrite). With `entries_at`'s rewrite unsynchronized, a `Bun.build()` on the bundler thread can drop the map while `reload()` on the JS thread is mid-iteration. The generation mismatch is what makes `entries_at` enter its rewrite branch, so the window only opens once the bundle thread has processed at least one batch (it bumps its own generation after every queue drain); every subsequent `Bun.build()` then re-reads any directory that `reload()` just refreshed to generation 0. ASAN catches it as a heap-use-after-free with the two sides of the race laid out exactly: ``` READ of size 16 (thread T0): #6 HashMap::values #7 StringHashMap<*mut Entry>::values src/collections/array_hash_map.rs:1864 #8 FileSystemRouter::bust_dir_cache_recursive src/runtime/api/filesystem_router.rs:395 #9 FileSystemRouter::bust_dir_cache src/runtime/api/filesystem_router.rs:451 #10 FileSystemRouter::reload src/runtime/api/filesystem_router.rs:476 freed by thread T11 (Bundler): #11 drop_in_place<bun_resolver::fs_full::DirEntry> #12 bun_resolver::fs::RealFS::entries_at src/resolver/lib.rs:1639 #13 DirInfo::get_entries_ref src/resolver/dir_info.rs:266 #14 Resolver::finalize_result src/resolver/resolver.rs:1714 #15 Resolver::resolve_and_auto_install src/resolver/resolver.rs:1485 ... #23 BundleThread::generate_in_new_thread src/bundler/BundleThread.rs:276 previously allocated by thread T0: #17 HashMap::reserve #18 Resolver::dir_info_cached_miss src/resolver/resolver.rs:4591 #19 Resolver::dir_info_cached_maybe_log src/resolver/resolver.rs:4201 #20 Resolver::read_dir_info src/resolver/resolver.rs:4118 #21 FileSystemRouter::reload src/runtime/api/filesystem_router.rs:492 ``` (The use side is sometimes `RouteLoader::load` at `src/router/lib.rs:816` instead; same map, same lock.) This has been the shape of `entries_at` since the Rust port; oven-sh#33056 narrowed the race by snapshotting under the lock but assumed the rewrite side already held it. ## Fix `entries_at` now takes `entries_mutex` itself, matching `read_directory_with_iterator` which already does. The one call path that reaches it with the lock already held (`dir_info_cached_miss` -> `dir_info_uncached` -> `parent_.get_entries_ref`) routes through a new `entries_at_locked` / `get_entries_ref_locked` pair so the non-recursive mutex is not re-entered. That path is the only one that passes a non-`None` parent to `dir_info_uncached`; the other caller (`dir_info_for_resolution`) passes `None`, so the parent branch containing the accessor never runs there. ## Test The existing concurrency test now awaits one `Bun.build()` first, so the bundle thread's generation is already past zero when the concurrent rounds start, and then runs forty reload/build rounds instead of one. That is the shape that reaches the stale-generation rewrite at all; the original single-round fixture usually completes with every build still on generation 0. The race is scheduling-dependent. Pinning the fixture to a single core reproduces the ASAN use-after-free on roughly 3 in 10 runs against an unpatched debug build and 0 in 15 with this change; with all 16 cores available the unpatched build reproduces at roughly 1 in 30. The assertions are otherwise the same as before, so the test continues to cover the behavior oven-sh#33056 added. Also ran the full `filesystem_router.test.ts`, `test/bundler/bun-build-api.test.ts` (including the thousands-of-builds test that exercises the generation path heavily), `test/js/bun/resolve/resolve.test.ts`, `test/cli/hot/hot.test.ts`, `test/cli/watch/watch.test.ts`, `test/bake/framework-router.test.ts`, and `bun run rust:check-all` (10/10 targets). <!-- robobun:evidence:begin --> --- **no test proof** · iteration 0 · Platform-specific test(s) that do not run on this machine. Deferring to CI, which covers all platforms: test/js/bun/util/filesystem_router.test.ts <!-- robobun:evidence:end -->
crishoj
pushed a commit
that referenced
this pull request
Jul 29, 2026
…aking it (oven-sh#36335) ## Problem `test/cli/install/bun-info.test.ts` (and its sibling `bun-audit.test.ts`) started aborting on the `:debian: 13 x64-asan` PR lane with a LeakSanitizer report after oven-sh#36175 landed (observed on builds 84674 / 84751 / 84815 / 84881): ``` ==19020==ERROR: LeakSanitizer: detected memory leaks Direct leak of 512 byte(s) in 1 object(s) allocated from: ... #16 in <bun_http::HTTPClient>::clone_metadata src/http/lib.rs:3977:13 #17 in handle_on_data_headers<true> src/http/lib.rs:3761:14 ... #26 in <bun_http::http_thread::HttpThread>::process_events ``` ## Cause `AsyncHTTP::send_sync` wrapped the terminal `HTTPResponseMetadata` in `ManuallyDrop` and returned the inner `picohttp::Response<'static>`: ```rust let metadata = core::mem::ManuallyDrop::new(metadata); Ok(metadata.response) ``` This was carried over from the Zig port (the original `sendSync` returned the bare `Response` and never `deinit`'d the metadata). It leaks two heap allocations per call: the `Box<[Header]>` leaked via `heap::release` in `clone_metadata`, and the `StringBuilder`-owned `owned_buf` that holds status text / header names / header values. Every sync CLI request goes through this path: `bun info` / `bun pm view`, `bun audit`, `bun publish` (up to four times with the OTP retry), `bun upgrade`, `bun create`, and `build --compile`'s target download. LSan's default scan is conservative, treating stacks and registers of every thread as roots. The only live reference to the leaked header slice after the command returns is the `Response` alias stored in `real.response` by `send_sync_callback`, and that lives on a frame already below the main thread's SP when `Global::exit` runs the leak check. Whether LSan still sees it depends on whether a thread happened to park in epoll / a futex with a stale pointer to the slice in a callee-saved register. On the x64-asan PR lane it stopped being hidden after oven-sh#36175; locally it stays hidden unless registers are excluded as roots. A fix for this leak already exists on the `farm/3977ed4f/linux-arm64-asan-ci` branch (7f1803a) and in oven-sh#36173; this PR extracts just the leak fix to unblock the x64-asan lane. ## Fix Return the owning `HTTPResponseMetadata` from `send_sync`. Accessor methods (`status_code()`, `status_text()`, `header()`, `header_if_other_is_absent()`) hand out reborrows tied to `&self` so borrowck enforces that no slice escapes the metadata's scope; the inner `Response` is typed `'static` but its slices borrow the sibling `owned_buf` / header slice that `Drop` frees. Callers switch from `res.status_code` / `res.headers.get(..)` to the accessor form. `npm::response_error` now takes `&HTTPResponseMetadata` directly. `send_sync_callback` writes `real.response = None` instead of copying the alias back into the caller's `AsyncHTTP`, since that stored copy would dangle once the returned metadata is dropped and no sync caller reads `self.response`. ## Test Added an ASAN-gated case to `bun-info.test.ts` that runs `bun info` against a local `Bun.serve` registry with `LSAN_OPTIONS=use_registers=0` so the leak is observed deterministically, and asserts a combined `{ stdout, stderr, exitCode }` result with LSan's default non-zero exit left intact. ``` # fail-before (src/ reverted to main, debug build) (fail) bun info does not leak the sync response metadata [5307ms] SUMMARY: AddressSanitizer: 206 byte(s) leaked in 2 allocation(s). # pass-after bun bd test test/cli/install/bun-info.test.ts 20 pass 0 fail (new leak test: 223ms) bun bd test test/cli/install/bun-audit.test.ts # 16 pass bun bd test test/cli/install/bun-create.test.ts # 19 pass bun bd test test/cli/install/bun-upgrade.test.ts # 8 pass ``` <!-- robobun:evidence:begin --> --- **[review]** gate passed · iteration 1 · 10 files touched <details><summary>fails on main (without fix)</summary> ```console ASAN without fix: 1 FAILED $ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/cli/install/bun-info.test.ts bun test v1.4.0 (8f0ef47) test/cli/install/bun-info.test.ts: (pass) bun info > bun info (main command) > should display package info for latest version [359.12ms] (pass) bun info > bun info (main command) > should handle missing arguments [346.80ms] (pass) bun info > bun info (main command) > should display package info for specific version [402.47ms] (pass) bun info > bun pm view (alias) > should display package info for latest version [380.58ms] (pass) bun info > bun info (main command) > should display specific property [484.38ms] (pass) bun info > bun pm view (alias) > should display package info for specific version [380.99ms] (pass) bun info > bun pm view (alias) > should display nested property [324.88ms] (pass) bun info > bun pm view (alias) > should handle non-existent package [297.70ms] (pass) bun info > bun pm view (alias) > should display specific property [1379.12ms] (pass) bun info > bun pm view (alias) > should output JSON format with --json flag [1356.80ms] (pass) bun info > bun pm v ... (truncated) release without fix: 1 skipped bun test v1.4.0-canary.1 (b4544d0) test/cli/install/bun-info.test.ts: (pass) bun info > bun info (main command) > should display package info for latest version [69.02ms] (pass) bun info > bun info (main command) > should handle missing arguments [68.71ms] (pass) bun info > bun pm view (alias) > should handle non-existent package [62.61ms] (pass) bun info > bun pm view (alias) > should display package info for latest version [71.24ms] (pass) bun info > bun pm view (alias) > should display nested property [69.87ms] (pass) bun info > bun pm view (alias) > should handle . [61.86ms] (pass) bun info > bun info (main command) > should display package info for specific version [75.65ms] (pass) bun info > bun info (main command) > should display specific property [77.38ms] (pass) bun info > bun pm view (alias) > should output JSON format with --json flag [78.60ms] (pass) bun info > bun pm view (alias) > versions[0] should work [71.64ms] (pass) bun info > bun pm view (alias) > versions should work [75.43ms] (pass) bun info > bun pm view (alias) > should handle dist-tags like latest [74.19ms] (pass) bun info > bun pm view (alias) > should handle version ranges [78.07ms] (p ... (truncated) ``` </details> <details><summary>passes on PR (with fix)</summary> ```console ASAN with fix: all passed $ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/mechgate.xml" test/cli/install/bun-info.test.ts bun test v1.4.0 (8f0ef47) test/cli/install/bun-info.test.ts: (pass) bun info > bun info (main command) > should display package info for latest version [349.74ms] (pass) bun info > bun info (main command) > should display package info for specific version [468.60ms] (pass) bun info > bun info (main command) > should display specific property [469.69ms] (pass) bun info > bun info (main command) > should handle missing arguments [475.25ms] (pass) bun info > bun pm view (alias) > should display package info for latest version [506.84ms] (pass) bun info > bun pm view (alias) > should display package info for specific version [460.48ms] (pass) bun info > bun pm view (alias) > should display nested property [392.82ms] (pass) bun info > bun pm view (alias) > should display specific property [507.04ms] (pass) bun info > bun pm view (alias) > should handle non-existent package [458.13ms] (pass) bun info > bun pm view (alias) > should output JSON format with --json flag [575.15ms] (pass) bun info > bun pm vie ... (truncated) release with fix: 1 skipped $ bun scripts/build.ts --profile=release [configured] bun-profile → bun (stripped) in 1113ms (unchanged) ninja: Entering directory `/workspace/bun/build/release' [1/6] gen generated_host_exports.rs generated_host_exports.rs: 94 exports (host=3, lazy=10, generic=81, rust=0); 240 extern-C blocks audited [1/6] cargo bun_bin → libbun_rust.a (--target x86_64-unknown-linux-gnu) nightly-2026-07-20-x86_64-unknown-linux-gnu unchanged - rustc 1.99.0-nightly (9f36de775 2026-07-19) �[1m�[92m Compiling�[0m bun_core v0.0.0 (/workspace/bun/src/bun_core) �[1m�[92m Compiling�[0m bun_errno v0.0.0 (/workspace/bun/src/errno) �[1m�[92m Compiling�[0m bun_ptr v0.0.0 (/workspace/bun/src/ptr) �[1m�[92m Compiling�[0m bun_boringssl_sys v0.0.0 (/workspace/bun/src/boringssl_sys) �[1m�[92m Compiling�[0m bun_safety v0.0.0 (/workspace/bun/src/safety) �[1m�[92m Compiling�[0m bun_zlib_sys v0.0.0 (/workspace/bun/src/zlib_sys) �[1m�[92m Compiling�[0m bun_cares_sys v0.0.0 (/workspace/bun/src/cares_sys) �[1m�[92m Compiling�[0m bun_zstd v0.0.0 (/workspace/bun/src/zstd) �[1m�[92m Compiling�[0m bun_collections v0.0.0 (/workspace/bun/src/collections) �[1m�[92m Compiling�[0m bun_p ... (truncated) ``` </details> <details><summary>diff hotspot</summary> ``` src/http/AsyncHTTP.rs | 12 +++-- src/http/lib.rs | 22 +++++++++ src/install/npm.rs | 23 +++++----- src/runtime/cli/audit_command.rs | 4 +- src/runtime/cli/create_command.rs | 14 +++--- src/runtime/cli/pm_view_command.rs | 2 +- src/runtime/cli/publish_command.rs | 28 +++++------- src/runtime/cli/upgrade_command.rs | 4 +- src/standalone_graph/StandaloneModuleGraph.rs | 2 +- test/cli/install/bun-info.test.ts | 65 +++++++++++++++++++++++++-- 10 files changed, 125 insertions(+), 51 deletions(-) ``` </details> **gate history** · 2 passed · 1 rejected · iteration 1 <details><summary>evidence per changed file</summary> ``` file reads edits tests src/http/AsyncHTTP.rs 5 6 0 src/http/lib.rs 5 4 0 src/install/npm.rs 0 0 0 src/runtime/cli/audit_command.rs 1 0 0 src/runtime/cli/create_command.rs 2 0 0 src/runtime/cli/pm_view_command.rs 2 0 0 src/runtime/cli/publish_command.rs 2 0 0 src/runtime/cli/upgrade_command.rs 1 0 0 src/standalone_graph/StandaloneModuleGraph.rs 1 0 0 test/cli/install/bun-info.test.ts 6 11 0 ``` </details> <!-- robobun:evidence:end --> --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Updates lolhtml to version v2.7.1
Compare: cloudflare/lol-html@d64457d...e9e16dc
Auto-updated by this workflow